package com.kgc.storeprovider.service.impl;

import com.kgc.basic.util.ResponseMsg;
import com.kgc.store.pojo.InventoryLossDetail;
import com.kgc.store.pojo.InventoryProfitDetail;
import com.kgc.storeprovider.dao.InventoryProfitDetailMapper;
import com.kgc.storeprovider.service.InventoryProfitDetailService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InventoryProfitDetailServiceImpl implements InventoryProfitDetailService {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private InventoryProfitDetailMapper inventoryProfitDetailMapper;
    @Override
    public ResponseMsg getInventoryProfitDetailList(String inventoryProfitCode) {
        logger.info("InventoryProfitDetailServiceImpl getInventoryProfitDetailList inventoryProfitCode:"+inventoryProfitCode);
        ResponseMsg msg = new ResponseMsg();
        List<InventoryProfitDetail> inventoryProfitDetailList = inventoryProfitDetailMapper.getInventoryProfitDetailList(inventoryProfitCode);
        logger.debug("InventoryProfitDetailServiceImpl getInventoryProfitDetailList inventoryProfitDetailList:"+inventoryProfitDetailList);
        msg.setCode("200");
        msg.setData(inventoryProfitDetailList);
        logger.debug("InventoryProfitDetailServiceImpl getInventoryProfitDetailList msg:"+msg);
        return msg;
    }

    @Override
    public ResponseMsg delInventoryProfitDetail(String inventoryProfitCode) {
        ResponseMsg msg = new ResponseMsg();
        int delCount = inventoryProfitDetailMapper.delInventoryProfitDetail(inventoryProfitCode);
        if(delCount>0){
            msg.setData(true);
            msg.setCode("200");
        }else{
            msg.setData(false);
            msg.setCode("201");
        }
        return msg;
    }

    @Override
    public ResponseMsg insertInventoryProfitDetail(InventoryProfitDetail inventoryProfitDetail) {
        ResponseMsg msg = new ResponseMsg();
        int insertCount = inventoryProfitDetailMapper.insertInventoryProfitDetail(inventoryProfitDetail);
        if(insertCount>0){
            msg.setData(true);
            msg.setCode("200");
        }else{
            msg.setData(false);
            msg.setCode("201");
        }
        return msg;
    }
}
